<script src="/js/popper.min.js"
    crossorigin="anonymous"></script>
<script src="/js/bootstrap.min.js"
    crossorigin="anonymous"></script>

{{ if .Site.Params.mermaid.enable }}
<script src="/js/mermaid.min.js" crossorigin="anonymous"></script>
{{ end }}

{{ if .Site.Params.markmap.enable }}
<style>
.markmap > svg {
  width: 100%;
  height: 300px;
}
</style>
<script>
window.markmap = {
  autoLoader: { manual: true },
};
</script>
<script src="/js/markmap-autoloader"></script>
{{ end }}

<script src='{{ "/js/tabpane-persist.js" | relURL }}'></script>

<!-- load the deflate.js for plantuml support -->
{{ if .Site.Params.plantuml.enable }}
<script src='{{ "/js/deflate.js" | relURL }}'></script>
{{ end }}

<!-- load stylesheet and scripts for KaTeX support -->
{{ if .Site.Params.katex.enable }}
<link rel="stylesheet" href="/css/katex.min.css" crossorigin="anonymous">
<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="/js/katex.min.js"
    crossorigin="anonymous"></script>
<!-- check whether support of mhchem is enabled in config.toml -->
{{ if .Site.Params.katex.mhchem.enable }}
<!-- To add support for displaying chemical equations and physical units, load the mhchem extension: -->
<script defer src="/js/mhchem.min.js"
    crossorigin="anonymous"></script>
{{ end }}
<!-- To automatically render math in text elements, include the auto-render extension: -->
<script defer src='/js/auto-render.min.js' crossorigin='anonymous' 
    {{ printf "onload='renderMathInElement(%s, %s);'" (( .Site.Params.katex.html_dom_element | default "document.body" ) | safeJS ) ( printf "%s" ( $.Site.Params.katex.options | jsonify )) | safeHTMLAttr }}></script>
{{ end }}

{{ $jsBase := resources.Get "js/base.js" }}
{{ $jsAnchor := resources.Get "js/anchor.js" }}
{{ $jsSearch := resources.Get "js/search.js" | resources.ExecuteAsTemplate "js/search.js" .Site.Home }}
{{ $jsMermaid := resources.Get "js/mermaid.js" | resources.ExecuteAsTemplate "js/mermaid.js" . }}
{{ $jsMarkmap := resources.Get "js/markmap.js" | resources.ExecuteAsTemplate "js/markmap.js" . }}
{{ $jsPlantuml := resources.Get "js/plantuml.js" | resources.ExecuteAsTemplate "js/plantuml.js" . }}
{{ $jsDrawio := resources.Get "js/drawio.js" | resources.ExecuteAsTemplate "js/plantuml.js" .}}
{{ if .Site.Params.offlineSearch }}
{{ $jsSearch = resources.Get "js/offline-search.js" }}
{{ end }}
{{ $js := (slice $jsBase $jsAnchor $jsSearch $jsMermaid $jsPlantuml $jsMarkmap $jsDrawio) | resources.Concat "js/main.js" }}
{{ if not hugo.IsProduction }}
<script src="{{ $js.RelPermalink }}"></script>
{{ else }}
{{ $js := $js | minify | fingerprint }}
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ if .Site.Params.prism_syntax_highlighting }}
<!-- scripts for prism -->
<script src='{{ "/js/prism.js" | relURL }}'></script>
{{ end }}
{{ partial "hooks/body-end.html" . }}
